<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title>后台</title>
		<link rel="stylesheet" href="/static/admin/css/style.css">
	</head>
	<body>
		<div class="wrap wrap-category-edit">
			<h1>栏目管理</h1>
			<div class="tips"></div>
			<div class="box">
				<div class="box-title">修改信息</div>	
				<div class="box-body">
<!--					<form method="post" action="?id=6&token=d1d8da704cea56e9045df5ca761993c0">-->
						<table>
							<tr><th width="80">栏目名称：</th><td><input type="text" name="name" value="{$data.name}"></td></tr>
							<input type="hidden" name="myId" value="{$data.id}">
							<tr><th>上级节点：</th>
								<td><select name="pid">
								{if $data.p_id == 0}
									<option value="">无</option>
								{else /}
									{foreach $list as $v}
										{if $data.p_id == $v.id}
										<option value="{$data.p_id}">无</option>
										<option value="{$v.id}" selected>{$v.name}</option>
										{else /}
										<option value="{$v.id}">{$v.name}</option>
										{/if}
									{/foreach}
								{/if}
									</select>
							</tr>
							<tr><th>显示顺序：</th><td><input type="text" class="s-num" name="sort" value="{$data.sort}"></td></tr>
							<tr class="s-act"><th></th><td><input type="submit" onclick="save()" value="提交更改"></td></tr>
						</table>
<!--					</form>-->
				</div>
			</div>
		</div>
	</body>
</html>
<script src="/static/admin/js/jquery.2.1.4.min.js"></script>
<script>
	function save(){
		$.ajax({
			url:'http://www.tp6cms.com/index.php/index/category/cp_category_edit',
			type:'POST',
			data:{
				name:$('input[name="name"]').val(),
				p_id:$('select[name="pid"]').val(),
				sort:$('input[name="sort"]').val(),
				id:$('input[name="myId"]').val(),
			},
			success:function (res){
				if(res.code==0){
					alert(res.msg);
				}else{
					alert(res.msg);
					setTimeout(()=>{
						window.location='http://www.tp6cms.com/index.php/index/category/cp_category';
					},100);
				}
			}

		})

	}




</script>